//
//  ReadWriteLocationCity.m
//  EasyToTesco2.0
//
//  Created by baozi on 16/8/22.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "ReadWriteLocationCity.h"

@implementation ReadWriteLocationCity

+ (void)saveLocationCity:(NSString *)locationCityString {
    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
    if (userDef) {
        
//        if (locationCityString.length == 3) {
//            NSInteger length = locationCityString.length;
//            NSString *cityString = [locationCityString substringWithRange:NSMakeRange(0, length - 1)];
//            NSLog(@"%@",cityString);
//            [userDef setObject:cityString forKey:@"user"];
//            [userDef synchronize];
//        } else {
            [userDef setObject:locationCityString forKey:@"user"];
            [userDef synchronize];
//        }
    }
}

+ (NSString *)ReadLocatinoCity {
    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
    if (userDef) {
        return  [userDef objectForKey:@"user"];
    }
    return nil;
}

+ (void)cleanLocatinCity {
    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
    if (userDef) {
        [userDef setObject:@"" forKey:@"user"];
        [userDef synchronize];
    }
    
}

+ (void)saveLocationString:(NSString *)locationCityString {
    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
    if (userDef) {
        [userDef setObject:locationCityString forKey:@"location"];
        [userDef synchronize];
    }
}

+ (NSString *)ReadLocationString {
    NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
    if (userDef) {
        return  [userDef objectForKey:@"location"];
    }
    return nil;
}

@end
